const { defineConfig } = require('@vue/cli-service')
const Mock = require('mockjs')
const data = Mock.mock({
  "list|10": [{
    "id": "@id",
    "image": "@image(150x120, @color)",
    "title": "@ctitle",
    "desc": "@word(10, 20)"
  }]
})
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    setupMiddlewares(middlewares, devServer) {
      devServer.app.get('/api/list', (req, res) => res.send(data.list));


      devServer.app.get('/api/list/detail', (req, res) => {
        const { id } = req.query;
        const item = data.list.find(v => v.id === id)
        res.send(item)
      
      })
      return middlewares
    }
  }
})
